package com.prolificinteractive.materialcalendarview;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.os.Build;
import android.view.Gravity;
import android.widget.TextView;

import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;

import java.util.Calendar;

/**
 * Display a day of the week
 */
@Experimental
@SuppressLint("ViewConstructor")
class WeekDayView extends TextView {

    private WeekDayFormatter formatter = WeekDayFormatter.DEFAULT;
    private int dayOfWeek;

    public WeekDayView(Context context, int dayOfWeek) {
        super(context);
        setGravity(Gravity.CENTER);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            setTextAlignment(TEXT_ALIGNMENT_CENTER);
        }
        this.dayOfWeek = dayOfWeek;
        setBackgroundColor(Color.parseColor("#FFf0eff5"));
        //setLayoutParams(new La);
       // setPadding(0,0,0,0);
        switch (dayOfWeek){
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                setTextColor(Color.parseColor("#FF4cc9d5"));
                break;
            case 1:
            case 7:
                setTextColor(Color.parseColor("#FFf67b71"));
                break;
        }
        setDayOfWeek(dayOfWeek);
    }

    public void setWeekDayFormatter(WeekDayFormatter formatter) {
        this.formatter = formatter == null ? WeekDayFormatter.DEFAULT : formatter;
       // setDayOfWeek(dayOfWeek);
    }

    public void setDayOfWeek(int dayOfWeek) {

   /*     switch (dayOfWeek){
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                setTextColor(Color.parseColor("#FFf67b71"));
                break;
            case 1:
            case 7:
                setTextColor(Color.parseColor("#FF4cc9d5"));
                break;
        }*/
        //setTextColor(Color.parseColor("#FFf67b71"));
        CharSequence name="";
        switch (dayOfWeek){
            case 1:
                name="日";
                break;
            case 2:
                name="一";
                break;
            case 3:
                name="二";
                break;
            case 4:
                name="三";
                break;
            case 5:
                name="四";
                break;
            case 6:
                name="五";
                break;
            case 7:
                name="六";
                break;
        }
      //  CharSequence name=formatter.format(dayOfWeek);
       setText(name);
    }

    public void setDayOfWeek(Calendar calendar) {
        setDayOfWeek(CalendarUtils.getDayOfWeek(calendar));
    }
}
